home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH09 / PGM9_2.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-02-08  |  2.6 KB  |  174 lines

  1. ; Pgm9_2.ASM
  2. ;
  3. ; This program demonstrates DeMorgan's theorems and
  4. ; various other logical computations.
  5.  
  6.  
  7.         .xlist
  8.         include     stdlib.a
  9.         includelib    stdlib.lib
  10.         .list
  11.  
  12.  
  13. dseg        segment    para public 'data'
  14.  
  15.  
  16. ; Boolean input variables for the various functions
  17. ; we are going to test.
  18.  
  19. a        byte    0
  20. b        byte    0
  21.  
  22.  
  23. dseg        ends
  24.  
  25.  
  26.  
  27. cseg        segment    para public 'code'
  28.         assume    cs:cseg, ds:dseg
  29.  
  30.  
  31. ; Get0or1-    Reads a "0" or "1" from the user and returns its
  32. ;        its value in the AX register.
  33.  
  34. get0or1        textequ    <call _get0or1>
  35. _get0or1    proc
  36.         push    es
  37.         push    di
  38.  
  39.         getsm
  40.         atoi
  41.         free
  42.  
  43.         pop    di
  44.         pop    es
  45.         ret
  46. _get0or1    endp
  47.  
  48.  
  49.  
  50.  
  51. Main        proc
  52.         mov    ax, dseg
  53.         mov    ds, ax
  54.         mov    es, ax
  55.         meminit
  56.  
  57.  
  58.         print
  59.         byte    "Demorgan's Theorems",cr,lf
  60.         byte    "-------------------",cr,lf
  61.         byte    lf
  62.         byte    "According to Demorgan's theorems, all results "
  63.         byte    "between the dashed lines",cr,lf
  64.         byte    "should be equal.",cr,lf
  65.         byte    lf
  66.         byte    "Enter a value for a: ",0
  67.  
  68.         get0or1
  69.         mov    a, al
  70.  
  71.         print
  72.         byte    "Enter a value for b: ",0
  73.         get0or1
  74.         mov    b, al
  75.  
  76.  
  77.         print
  78.                 byte    "---------------------------------",cr,lf
  79.         byte    "Computing not (A and B): ",0
  80.  
  81.         mov    ah, 0
  82.         mov    al, a
  83.         and    al, b
  84.         xor    al, 1        ;Logical NOT operation.
  85.  
  86.         puti
  87.         putcr
  88.  
  89.         print
  90.         byte    "Computing (not A) OR (not B): ",0
  91.         mov    al, a
  92.         xor    al, 1
  93.         mov    bl, b
  94.         xor    bl, 1
  95.         or    al, bl
  96.         puti
  97.  
  98.         print
  99.         byte    cr,lf
  100.         byte    "---------------------------------",cr,lf
  101.         byte    "Computing (not A) OR B: ",0
  102.         mov    al, a
  103.         xor    al, 1
  104.         or    al, b
  105.         puti
  106.  
  107.         print
  108.         byte    cr,lf
  109.         byte    "Computing not (A AND (not B)): ",0
  110.         mov    al, b
  111.         xor    al, 1
  112.         and    al, a
  113.         xor    al, 1
  114.         puti
  115.  
  116.         print
  117.         byte    cr,lf
  118.         byte    "---------------------------------",cr,lf
  119.         byte    "Computing (not A) OR B: ",0
  120.         mov    al, a
  121.         xor    al, 1
  122.         or    al, b
  123.         puti
  124.  
  125.         print
  126.         byte    cr,lf
  127.         byte    "Computing not (A AND (not B)): ",0
  128.         mov    al, b
  129.         xor    al, 1
  130.         and    al, a
  131.         xor    al, 1
  132.         puti
  133.  
  134.         print
  135.         byte    cr,lf
  136.         byte    "---------------------------------",cr,lf
  137.         byte    "Computing not (A OR B): ",0
  138.         mov    al, a
  139.         or    al, b
  140.         xor    al, 1
  141.         puti
  142.  
  143.         print
  144.         byte    cr,lf
  145.         byte    "Computing (not A) AND (not B): ",0
  146.         mov    al, a
  147.         xor    al, 1
  148.         and    bl, b
  149.         xor    bl, 1
  150.         and    al, bl
  151.         puti
  152.  
  153.         print
  154.         byte    cr,lf
  155.         byte    "---------------------------------",cr,lf
  156.         byte    0
  157.  
  158.  
  159.  
  160.  
  161. Quit:        ExitPgm            ;DOS macro to quit program.
  162. Main        endp
  163.  
  164. cseg        ends
  165.  
  166. sseg        segment    para stack 'stack'
  167. stk        byte    1024 dup ("stack   ")
  168. sseg        ends
  169.  
  170. zzzzzzseg    segment    para public 'zzzzzz'
  171. LastBytes    byte    16 dup (?)
  172. zzzzzzseg    ends
  173.         end    Main
  174.